package com.croofr.utils.configuration;

/**
 * This interface is used for operation with generic configuration.
 * Configufation may be stored in properties or xml files, ZooKeeper
 * server and etc. Configuration is use for <b>replace</b> java.util.Properties.
 * <p/>
 * User: bednar<br/>
 * Date: Jan 24, 2010<br/>
 * Time: 10:39:11 AM
 *
 * @see java.util.Properties
 */
public interface Configuration
{

    /**
     * Get string value from loaded configuration by key.
     *
     * @param key of entry
     * @return String value of entry or null if configuration hasn't entry with specified key
     */
    String getString(String key);

    /**
     * Get string value of entry loaded configuration by key or default value.
     *
     * @param key          of entry
     * @param defaultValue returned if configuration hasn't entry with specified key
     * @return String value of entry or default value if configuration hasn't entry (null or empty) with specified key
     */
    String getString(String key, String defaultValue);

    /**
     * Return number of entries in configuration.
     *
     * @return number of entries in configuration
     */
    Integer size();

    /**
     * Get enum entry for configuration value obtained by key.
     * If Enum hasn't entry with 'id' equals with configuration value,
     * than throw runtime exception.
     *
     * @param key       of entry in configuration
     * @param enumClass class of enum
     * @param <T>       type of enum
     * @return enum entry by configuration value by key
     * @see Enum#valueOf
     */
    <T extends Enum<T>> T getEnumEntry(String key, Class<T> enumClass);
}
